<!DOCTYPE html>
<head>
  <title>Inline continuations - accessibility tree linkage</title>
  <script src="../resources/js-test.js"></script>
  <script>
    if (window.testRunner)
      testRunner.dumpAsText();
  </script>
</head>
<body>

  <h2>Inline continuations - accessibility tree linkage</h2>

  <p>This test checks that the right accessibility tree is generated in the
      presence of inline continuations. Each of the five numbers below should
      be visited only ones traversing the accessibility tree.
  </p>

  <div contentEditable="true">
    <span>1<div role="group">2</div>3</span>
    <span>4</span>
    <div role="group">5</div>
  </div>

<script>
function NonGroupDescendants(elt) {
  let result = 0;
  let count = elt.childrenCount;
  for (let i = 0; i < count; ++i) {
    child = elt.childAtIndex(i);
    if (child.role != 'AXRole: AXGroup' &&
        child.role != 'AXRole: AXInlineTextBox' &&
        child.role != 'AXRole: AXGenericContainer') {
      result++;
    }
    result += NonGroupDescendants(child);
  }
  return result;
}

if (window.accessibilityController) {
  document.querySelector('[contenteditable]').focus();
  // The layout engine inserts an additional static text element containing a
  // space between "3" and "4".
  shouldBe('NonGroupDescendants(accessibilityController.focusedElement)', '6');
}

</script>

</body>
